#ifndef MATOPS_H
#define MATOPS_H

/***************************************************************************
				MatOps.h
                             ---------------
Copyright (c) 2009-2010 
Author: Kishor D. Bhalerao (kishor8dm@gmail.com)
Contributors: 

This file is associated with the Ph.D. dissertation,"ON METHODS FOR EFFICIENT
AND ACCURATE DESIGN AND SIMULATION OF MULTIBODY SYSTEMS", Bhalerao K.D,
Rensselaer Polytechnic Institute, 2010.

Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:

1.) Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

2.) Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation and/or
other materials provided with the distribution.

3.) The name of the authors, their employers, or sponsoring organizations may
not be used to endorse or promote products derived from this software without
specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
EVENT SHALL THE AUTHORS, THEIR EMPLOYERS, OR SPONSORING ORGANIZATIONS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
***************************************************************************/

// The use of class MatOp should be avoided. It slows the code. It was origianly
// written as a quick work around to make conversions between different types
// of SimTK Matrix classes. Perhaps there is a faster way to do this. Ask Sherm

#include "SimTKsimbody.h"
#include "Simbody.h"

using namespace SimTK;
struct EoMData;
class MatOp{
public:	
	void dispMat(Real *Mat,int Row, int Col);
	
	Mat55 toMat55(Matrix& m);
	
	Mat33 toMat33(Real *v);
	void toMat33(Real *v, Mat33 *m);
	Mat33 toMat33(Matrix& m);
	
	Matrix toMatrix(Mat33& mat);
	Matrix toMatrix(Mat66& mat);
	void toMatrix(Mat55& mat, Matrix& m);
	
	Mat66 toMat66(Mat33& m1, Mat33& m2, Mat33& m3, Mat33& m4);
	void toMat66(const Matrix& m,Mat66& op);
	
	void toVec6(Vec3& a,Vec3& b,Vec6& x);
	Vec6 toVec6(Vec3&a, Vec3& b);
	
	Vec3 toVec3(Vector& a);
	
	Vec3 CrossProduct(const Vec3& a, const Vec3& b);
	Vec3 CrossProduct(const Vec3& a,const Vector& b);
	
	void VectorCrossMatrix(Vec3 *a, Mat33 *CrossMat);
	
	void expressMat66inBasis(Mat66& H,const Mat66& Mat, Mat33& B_C_A);
	void expressVec6inBasis(Vec6& H,const Vec6& V,const Mat33& B_C_A);
};

#endif